﻿/*
*VMukti -- An open source video conferencing platform.
*
* Copyright (C) 2007 - 2008, VMukti Solutions Pvt. Ltd.
*
* Hardik Sanghvi <hardik@vmukti.com>
*
* See http://www.vmukti.com for more information about
* the VMukti project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, forums and mailing lists
* for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree..
*/


using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using VMukti.Business;
using VMukti.Business.CommonDataContracts;
using VMukti.Business.WCFServices.SuperNodeServices.BasicHttp;
using VMukti.Business.WCFServices.SuperNodeServices.NetP2P;
using VMukti.CtlResizer.Presentation;
using VMukti.Presentation.Controls;
using VMukti.Presentation.MainPod;
using VMukti.Presentation.Page_Tab;
using VMuktiAPI;
using VMuktiService;
using System.Net;
using System.Text;
using System.Diagnostics;
using VMukti.Business.WCFServices.BootStrapServices.NetP2P;


namespace VMukti.Presentation
{
	public partial class pgHome : Page, IDisposable
	{
		VMukti.Presentation.Page_Tab.CtlPageTab cpt = null;
        VMuktiGrid.ctlVMuktiGrid objVMuktiGrid = null;

		//ExecutorContainer _container = null;
		bool flagSignOut = false;
		NetPeerClient npcP2PSuperNode = null;
        StringBuilder sb1;

		#region Win32

		[DllImport("user32.dll")]
		static extern bool FlashWindow(IntPtr hwnd, bool bInvert);

		[DllImport("Kernel32.dll")]
		static extern bool Beep(uint dwFreq, uint dwDuration);

		[DllImport("user32.dll")]
		static extern bool FlashWindowEx(IntPtr hWnd);

		#endregion

		IntPtr hwnd;
		System.Windows.Threading.DispatcherTimer dispTimer4DomainLoading = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Normal);
		private DispatcherTimer dispTmrCheckStatus = new DispatcherTimer();


		public delegate void DelGetMessage();
		public DelGetMessage objDelGetMsg;

		//ColumnDefinition colDef3 = new ColumnDefinition();

		private bool disposed = false;

        System.Threading.Thread tConsoleClient;

        object objNetTcpConsole = new ClsNetP2PConsoleDelegates();
        INetP2PConsoleChannel objChannel;

        bool blnISConsole = false;

        Process pConsole;
        ProcessStartInfo psiConsole;

		public pgHome()
		{
			try
			{
				try
				{
					InitializeComponent();

                    
					dispTimer4DomainLoading.Tick += new EventHandler(dispTimer4DomainLoading_Tick);
					dispTimer4DomainLoading.Interval = TimeSpan.FromSeconds(1);

					dispTmrCheckStatus.Interval = TimeSpan.FromSeconds(3);
					dispTmrCheckStatus.Tick += new EventHandler(dispTmrCheckStatus_Tick);

					objDelGetMsg = new DelGetMessage(delGetMessage);

					this.ShowsNavigationUI = false;
					cnvMain.Width = System.Windows.SystemParameters.WorkArea.Width;
					cnvMain.Height = System.Windows.SystemParameters.WorkArea.Height;
				}
				catch (Exception ex)
				{
					ex.Data.Add("My Key", "pgHome()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
					ClsException.LogError(ex);
					ClsException.WriteToErrorLogFile(ex);
				}

				this.Loaded += new RoutedEventHandler(pgHome_Loaded);
				this.Unloaded += new RoutedEventHandler(pgHome_Unloaded);
				Application.Current.Exit += new ExitEventHandler(Current_Exit);
				this.AddHandler(ClsTabsTabItem.CloseTab, new RoutedEventHandler(this.closeTab));
				this.AddHandler(ClsTabsTabItem.RenameTab, new RoutedEventHandler(this.renameTab));
				this.AddHandler(ClsTabsTabItem.DeleteTab, new RoutedEventHandler(this.deleteTab));
				this.AddHandler(ClsTabsTabItem.TabBuddyEnter, new RoutedEventHandler(this.buddyEnterTab));
				this.AddHandler(ClsTabsTabItem.TabBuddyLeave, new RoutedEventHandler(this.buddyLeaveTab));

                //cpt = new VMukti.Presentation.Page_Tab.CtlPageTab();
                //cpt.EntChannelSetMsg += new CtlPageTab.DelChannelSetMsg(cpt_EntChannelSetMsg);
                ////cpt.EntChanneSetPageMsg += new CtlPageTab.DelChannelSetPageMsg(cpt_EntChannelSetPageMsg);
                //cpt.EntChannelSetPageMsg += new CtlPageTab.DelChannelSetPageMsg(cpt_EntChannelSetPageMsg);
                //cpt.EntChannelRemoveDraggedBuddy += new CtlPageTab.DelChannelRemoveBuddy(cpt_EntChannelRemoveDraggedBuddy);

                objVMuktiGrid = new VMuktiGrid.ctlVMuktiGrid();

                objModules.EntAutherized += new CtlModules.DelAutherized(objModules_EntAutherized);
				cmbThemes.SelectionChanged += new SelectionChangedEventHandler(cmbThemes_SelectionChanged);

				colDef3.Width = new GridLength(0);

				VMuktiAPI.VMuktiHelper.RegisterEvent("SignOutFlag").VMuktiEvent += new VMuktiEvents.VMuktiEventHandler(pgHome_VMuktiEvent);
                VMuktiAPI.VMuktiHelper.RegisterEvent("SendConsoleMessage").VMuktiEvent += new VMuktiEvents.VMuktiEventHandler(pgHome_VMuktiEvent_SendConsoleMsg);
                VMuktiAPI.VMuktiHelper.RegisterEvent("StopTimer").VMuktiEvent += new VMuktiEvents.VMuktiEventHandler(pgHome_VMuktiEvent_StopTimer);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "pgHome()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void cpt_EntChannelSetPageMsg(string from, string to, string msg, List<clsModuleInfo> cmi)
		{
			try
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode)
				{
                    //App.chNetP2PSuperNodeChannel.svcSetSpecialMsg(from, to, msg, cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
                    //App.chNetP2PSuperNodeChannel.svcAddDraggedBuddy(from, to, "Newly Dragged Buddy", cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);

				}
				else
				{
                    //App.chHttpSuperNodeService.svcSetSpecialMsgs(from, to, msg, cmi);
                    //App.chHttpSuperNodeService.svcAddDraggedBuddy(from, to, "Newly Dragged Buddy", cmi);
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "cpt_EntChannelSetMsg()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void cpt_EntChannelRemoveDraggedBuddy(string from, List<string> to, string msg, clsModuleInfo cmi)
		{
			try
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode)
				{
					//App.chNetP2PSuperNodeChannel.svcSetSpecialMsg(from, to, msg, cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
					App.chNetP2PSuperNodeChannel.svcSetRemoveDraggedBuddy(from, to, msg, cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
				}
				else
				{
					//                    App.chHttpSuperNodeService.svcSetSpecialMsgs(from, to, msg, cmi);
					App.chHttpSuperNodeService.svcSetRemoveDraggedBuddy(from, to, msg, cmi);
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "cpt_EntChannelRemoveDraggedBuddy()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void dispTimer4DomainLoading_Tick(object sender, EventArgs e)
		{
			lock (this)
			{
				try
				{
					StreamReader sReader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\DomainStatus.txt");
					string strStatus = sReader.ReadToEnd();
					sReader.Close();
					if (strStatus == "Initializing")
					{
						dispTimer4DomainLoading.Stop();

                        tConsoleClient = new System.Threading.Thread(new System.Threading.ThreadStart(OpenConsoleClient));
                        tConsoleClient.Start();

						try
						{
							//  ClsModuleCollection objCMC = null;
							//cpt.LoadTabControl(150);
							//scrViewTab.Content = cpt.LoadTabControl(scrViewLogin.Width);
							//cpt.LoadDefaultPage(cnvMain.Height, cnvMain.Width, scrViewLogin.Width, scrViewBuddy.Width);
                            if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap)
                            {
                                ClsModuleCollection objCMC = null;
                                objCMC = ClsModuleCollection.GetNonAuthenticatedMod();

                                for (int j = 0; j < objCMC.Count; j++)
                                {
                                    objModules.AddModule(objCMC[j].ModuleTitle, objCMC[j].ModuleId + ",ModuleType,False");
                                }
                            }
                            else if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.NodeWithHttp)
                            {
                                //App.chHttpDataBaseService = (IHttpDataBaseService)App.objHttpDataBase.OpenClient<IHttpDataBaseService>("http://" + VMuktiInfo.CurrentPeer.SuperNodeIP + ":80/HttpDataBase");
                                //App.chHttpDataBaseService.svcJoin();                                
                                if (Business.clsDataBaseChannel.OpenDataBaseClient())
                                {
                                    ClsModuleCollection objCMC = new ClsModuleCollection();
                                    //ClsModuleCollection objCMC = ClsModuleCollection.GetNonAuthenticatedMod();
                                    //System.Data.SqlClient.SqlParameter sp = new System.Data.SqlClient.SqlParameter();
                                    objCMC.MapObjects(Business.clsDataBaseChannel.chHttpDataBaseService.svcExecuteDataSet("select ModuleName,id,IsCollaborative,ZipFile,AssemblyFile from Module where NeedsAuthentication='false' order by ModuleName").dsInfo);

                                    for (int j = 0; j < objCMC.Count; j++)
                                    {
                                        objModules.AddModule(objCMC[j].ModuleTitle, objCMC[j].ModuleId + ",ModuleType,False");
                                    }
                                }
                            }
                            objModules.EntPageItemSelectionChanged += new VMukti.Presentation.Controls.CtlModules.DelPageItemSelectionChanged(objModules_EntPageItemSelectionChanged);

                            scrViewTab.Content = objVMuktiGrid;
                            //scrViewTab.Content = cpt.LoadTabControl(0);
                            //cpt.LoadDefaultPage(0, 0, 0, 0);
                            //cpt.AddNewPage();
						}
						catch (Exception ex)
						{
							ex.Data.Add("My Key", "pgHome_Loaded()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
							ClsException.LogError(ex);
							ClsException.WriteToErrorLogFile(ex);
						}
					}
					else
					{

					}
				}
				catch (Exception ex)
				{
					ex.Data.Add("My Key", "TimerTick 4 Domain()--:--PgHome.xaml.cs--:--" + ex.Message + " :--:--");
					ClsException.LogError(ex);
					ClsException.WriteToErrorLogFile(ex);
				}
			}
		}

		void pgHome_VMuktiEvent(object sender, VMuktiEventArgs e)
		{
			flagSignOut = true;
		}

        void pgHome_VMuktiEvent_StopTimer(object sender, VMuktiEventArgs e)
        {
            if (dispTimer4DomainLoading != null)
            {
                dispTimer4DomainLoading.Stop();
            }
            if (dispTmrCheckStatus != null)
            {
                dispTmrCheckStatus.Stop();
            }
        }

		void cmbThemes_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			try
			{
				objModules.btnClose_Click(null, null);
				objBuddies.btnClose_Click(null, null);
				btnPane_Click(null, null);
				if (((ComboBoxItem)cmbThemes.SelectedItem).Tag.ToString() == "Call Center")
				{
					//if (VMuktiAPI.VMuktiInfo.CurrentPeer.RoleID.ToString() == "1")
					//{
					//    objModules.LoadPage("CallCenter");
					//}
					//if (VMuktiAPI.VMuktiInfo.CurrentPeer.RoleID.ToString() == "2")
					//{
					//    objModules.LoadPage("AgentScreen");
					//}
                    System.Text.StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Home page: user changed the Theme");
                    sb.Append("Theme is :Call center");
                    sb.Append(sb1.ToString());
                    VMuktiAPI.ClsLogging.WriteToTresslog(sb);
					objModules.LoadPage("CallCenter");
                    
				}
				else
				{
					//MessageBox.Show("In Design mode!!");
                    System.Text.StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Home page: user changed the Theme");
                    sb.Append("Theme is :Meeting");
                    sb.Append(sb1.ToString());
                    VMuktiAPI.ClsLogging.WriteToTresslog(sb);
					objModules.LoadPage("Meeting");
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "cmbThemes_SelectionChanged()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void Current_Exit(object sender, ExitEventArgs e)
		{
			try
			{
				if (!isEventOccured)
				{
					LogOut();
					isEventOccured = true;
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "Current_Exit()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		bool isEventOccured = false;

		void pgHome_Unloaded(object sender, RoutedEventArgs e)
		{
			try
			{
				if (!isEventOccured)
				{
					LogOut();
					isEventOccured = true;
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "pgHome_Unloaded()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void btnLogin_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				btnMExp_Click(null, null);

				if (btnLogin.Content.ToString() == "Sign In")
				{
					//btnLogin.Content = "Sign Out";
				}
				else if (btnLogin.Content.ToString() == "Sign Out")
				{
					App.SetCookie(BrowserInteropHelper.Source, "Login");

					objModules.LogOut();
					tblkUserName.Text = "";
					LogOut();
					btnLogin.Content = "Sign In";

				}

				objModules.ShowLogin();
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "btnLogin_Click()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}

		}

		void LogOut()
		{
			try
			{
				//  if (btnLogin.Content.ToString() != "Sign In")
                if (!isEventOccured)
				{
                    isEventOccured = true;
					VMuktiAPI.VMuktiHelper.CallEvent("SignOut", null, null);

                    //Add code for VMuktiGrid
                    //cpt.ptc.Items.Clear();
                    //cpt.LoadDefaultPage(0, 0, 0, 0);
                    //cpt.AddNewPage();

					VMuktiAPI.VMuktiHelper.CallEvent("LogoutBuddyList", this, new VMuktiEventArgs());
					if (App.chHttpSuperNodeService != null)
					{
						App.chHttpSuperNodeService.svcUnjoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
						App.objHttpSuperNode.CloseClient<IHttpSuperNodeService>();

					}
					bool isSuperNode = false;
					if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode)
					{
						isSuperNode = true;
					}
					if (App.chHttpBootStrapService != null)
					{
						App.chHttpBootStrapService.svcHttpBSUnJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, GetIP4Address(), isSuperNode);
					}

					if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.NodeWithNetP2P)
					{
						if (App.chNetP2PSuperNodeChannel != null && App.chNetP2PSuperNodeChannel.State == System.ServiceModel.CommunicationState.Opened)
						{
							App.chNetP2PSuperNodeChannel.Close();
							npcP2PSuperNode.CloseClient<INetP2PSuperNodeChannel>();
							App.objNetP2PSuperNode = null;
						}
					}

					if (dispTmrCheckStatus != null)
					{
						dispTmrCheckStatus.Stop();
					}

				}

				btnBList.Visibility = Visibility.Collapsed;
				tblkTheme.Visibility = Visibility.Collapsed;
				cmbThemes.Visibility = Visibility.Collapsed;
				tblkUserName.Visibility = Visibility.Collapsed;
				btnSettings.Visibility = Visibility.Collapsed;
				btnLogin.Visibility = Visibility.Collapsed;
				scrViewBuddy.Visibility = Visibility.Collapsed;
				gsBuddy.Visibility = Visibility.Collapsed;

				//if (App.chNetP2PBootStrapActiveAgentReportChannel != null && App.chNetP2PBootStrapActiveAgentReportChannel.State != CommunicationState.Closed)
				//{
				//    App.chNetP2PBootStrapActiveAgentReportChannel.svcUnJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.ID.ToString());
				//    App.chNetP2PBootStrapActiveAgentReportChannel.Close();
				//}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "LogOut()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}
		
        string GetIP4Address()
		{
			string IP4Address = String.Empty;
			try
			{
				foreach (IPAddress IPA in Dns.GetHostAddresses(System.Net.Dns.GetHostName()))
				{
					if (IPA.AddressFamily.ToString() == "InterNetwork")
					{
						IP4Address = IPA.ToString();
						break;
					}
				}
				return IP4Address;
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "GetIP4Address--:--PgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
				return IP4Address;
			}
		}

		void objModules_EntAutherized()
		{
			try
			{
                isEventOccured = false;
				btnBList.Visibility = Visibility.Visible;
				tblkTheme.Visibility = Visibility.Visible;
				cmbThemes.Visibility = Visibility.Visible;
				tblkUserName.Visibility = Visibility.Visible;
				btnSettings.Visibility = Visibility.Visible;
				btnLogin.Visibility = Visibility.Visible;
				scrViewBuddy.Visibility = Visibility.Visible;
				gsBuddy.Visibility = Visibility.Visible;

                 if ((VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap) && VMuktiAPI.VMuktiInfo.CurrentPeer.RoleID==1)
                {
                    btnConsole.Visibility = Visibility.Visible;
                    
                }


				if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P)
				{
					npcP2PSuperNode = new NetPeerClient();
					App.objNetP2PSuperNode = new NetP2PSuperNodeDelegates();

					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcJoin += new NetP2PSuperNodeDelegates.DelsvcJoin(pgHome_EntsvcJoin);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcSetSpecialMsg += new NetP2PSuperNodeDelegates.DelsvcSetSpecialMsg(pgHome_EntsvcSetSpecialMsg);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcPageSetSpecialMsg += new NetP2PSuperNodeDelegates.DelsvcPageSetSpecialMsg(pgHome_EntsvcPageSetSpecialMsg);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcAddDraggedBuddy += new NetP2PSuperNodeDelegates.DelsvcAddDraggedBuddy(pgHome_EntsvcAddDraggedBuddy);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcAddPageDraggedBuddy += new NetP2PSuperNodeDelegates.DelsvcAddPageDraggedBuddy(pgHome_EntsvcAddPageDraggedBuddy);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcSetRemoveDraggedBuddy += new NetP2PSuperNodeDelegates.DelsvcSetRemoveDraggedBuddy(pgHome_EntsvcSetRemoveDraggedBuddy);
					((NetP2PSuperNodeDelegates)App.objNetP2PSuperNode).EntsvcUnJoin += new NetP2PSuperNodeDelegates.DelsvcUnJoin(pgHome_EntsvcUnJoin);

					App.chNetP2PSuperNodeChannel = (INetP2PSuperNodeChannel)npcP2PSuperNode.OpenClient<INetP2PSuperNodeChannel>("net.tcp://" + VMuktiInfo.CurrentPeer.SuperNodeIP + ":5002/NetP2PSuperNode", "P2PSuperNodeMesh", ref App.objNetP2PSuperNode);
					App.chNetP2PSuperNodeChannel.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
				}
				else if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp)
				{
					dispTmrCheckStatus.Start();
                }

                System.Text.StringBuilder sb = new StringBuilder();
                sb.AppendLine("Home page:User Authorised succesfully");
                sb1 = CreateTressInfo();
                sb.Append(sb1.ToString());
                VMuktiAPI.ClsLogging.WriteToTresslog(sb);
                //objModules.LoadPage("Meeting");
            }
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "pgHome_Loaded()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
			try
			{

				tblkUserName.Text = "Welcome ( " + VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName + " )";
				objBuddies.LoadBuddyList();
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.RoleID == 1)
				{
					btnSettings.Visibility = Visibility.Visible;
				}
				btnLogin.Content = "Sign Out";
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "objModules_EntAutherized()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void pgHome_EntsvcAddPageDraggedBuddy(string from, string to, string msg, List<clsModuleInfo> lstModInfo, string IPAddress)
		{
			if (from != VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName && to != VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName)
			{
				#region Tab Type
                //Add code for VMuktiGrid
                //if (lstModInfo[0].strDropType == "Tab Type")
                //{
                //    for (int i = 0; i < cpt.ptc.Items.Count; i++)
                //    {
                //        if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == lstModInfo[0].strPageid)
                //        {
                //            for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                //            {
                //                if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == lstModInfo[0].strTabid)
                //                {
                //                    bool blnTabNamePresent = false;

                //                    for (int lstTabBuddyCnt = 0; lstTabBuddyCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Count; lstTabBuddyCnt++)
                //                    {

                //                        if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged[lstTabBuddyCnt] == to)
                //                        {
                //                            blnTabNamePresent = true;
                //                            break;
                //                        }
                //                    }

                //                    if (!blnTabNamePresent)
                //                    {
                //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Add(to);
                //                        ComboItem cbi = new ComboItem();
                //                        cbi.setName(to);
                //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbi);
                //                    }


                //                    //((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Add(to);

                //                    //ComboItem cbi = new ComboItem();
                //                    //cbi.setName(to);
                //                    //((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbi);

                //                    for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                //                    {
                //                        bool blnNamePresent = false;

                //                        //((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);

                //                        //for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                //                        //{
                //                        //    ComboItem cbi1 = new ComboItem();
                //                        //    cbi1.setName(to);
                //                        //    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi1);

                //                        //}

                //                        for (int lstBuddyCnt = 0; lstBuddyCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Count; lstBuddyCnt++)
                //                        {
                //                            if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped[lstBuddyCnt] == to)
                //                            {
                //                                blnNamePresent = true;
                //                                break;
                //                            }
                //                        }
                //                        if (!blnNamePresent)
                //                        {
                //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);
                //                            ComboItem cbi = new ComboItem();
                //                            cbi.setName(to);
                //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi);
                //                        }
                //                    }
                //                }
                //            }
                //        }
                //    }
                //}


				#endregion

				#region Page Type
                //Add code for VMuktiGrid
                //else if (lstModInfo[0].strDropType == "Page Type")
                //{
                //    for (int i = 0; i < cpt.ptc.Items.Count; i++)
                //    {
                //        if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == lstModInfo[0].strPageid)
                //        {
                //            //((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged.Add(to);

                //            //ComboItem cbiPage = new ComboItem();
                //            //cbiPage.setName(to);

                //            //((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.Add(cbiPage);

                //            bool blnPageNamePresent = false;

                //            for (int lstPageBuddyCnt = 0; lstPageBuddyCnt < ((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged.Count; lstPageBuddyCnt++)
                //            {

                //                if (((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged[lstPageBuddyCnt] == to)
                //                {
                //                    blnPageNamePresent = true;
                //                    break;
                //                }
                //            }

                //            if (!blnPageNamePresent)
                //            {
                //                ((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged.Add(to);
                //                ComboItem cbi = new ComboItem();
                //                cbi.setName(to);
                //                ((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.Add(cbi);
                //            }





                //            for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                //            {
                //                if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Header.ToString() != "+")
                //                {
                //                    //((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Add(to);

                //                    //ComboItem cbiTab = new ComboItem();
                //                    //cbiTab.setName(to);

                //                    //((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbiTab);

                //                    bool blnTabNamePresent = false;

                //                    for (int lstTabBuddyCnt = 0; lstTabBuddyCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Count; lstTabBuddyCnt++)
                //                    {

                //                        if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged[lstTabBuddyCnt] == to)
                //                        {
                //                            blnTabNamePresent = true;
                //                            break;
                //                        }
                //                    }

                //                    if (!blnTabNamePresent)
                //                    {
                //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Add(to);
                //                        ComboItem cbi = new ComboItem();
                //                        cbi.setName(to);
                //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbi);
                //                    }


                //                    for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                //                    {
                //                        //((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);

                //                        //ComboItem cbiPod = new ComboItem();
                //                        //cbiPod.setName(to);

                //                        //((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbiPod);

                //                        bool blnNamePresent = false;

                //                        for (int lstBuddyCnt = 0; lstBuddyCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Count; lstBuddyCnt++)
                //                        {
                //                            if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped[lstBuddyCnt] == to)
                //                            {
                //                                blnNamePresent = true;
                //                                break;
                //                            }
                //                        }
                //                        if (!blnNamePresent)
                //                        {
                //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);
                //                            ComboItem cbi = new ComboItem();
                //                            cbi.setName(to);
                //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi);
                //                        }

                //                    }
                //                }
                //            }
                //        }
                //    }
                //}


				#endregion
			}
		}

		void pgHome_EntsvcAddDraggedBuddy(string from, string to, string msg, clsModuleInfo objModInfo, string IPAddress)
		{
			if (from != VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName && to != VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName)
			{
				#region Pod Type
                //Add code for VMuktiGrid
                //if (objModInfo.strDropType == "Pod Type")
                //{
                //    for (int i = 0; i < cpt.ptc.Items.Count; i++)
                //    {
                //        if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                //        {
                //            for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                //            {
                //                if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                //                {
                //                    for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                //                    {
                //                        bool blnNamePresent = false;

                //                        if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).PID == int.Parse(objModInfo.strPodid))
                //                        {
                //                            for (int lstBuddyCnt = 0; lstBuddyCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Count; lstBuddyCnt++)
                //                            {
                //                                if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped[lstBuddyCnt] == to)
                //                                {
                //                                    blnNamePresent = true;
                //                                    break;
                //                                }
                //                            }
                //                            if (!blnNamePresent)
                //                            {
                //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);
                //                                ComboItem cbi = new ComboItem();
                //                                cbi.setName(to);
                //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi);
                //                            }
                //                        }
                //                    }
                //                }
                //            }
                //        }
                //    }
                //}
				#endregion
			}
		}

		void pgHome_Loaded(object sender, RoutedEventArgs e)
		{
			//MessageBox.Show(((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))).ToString());
			dispTimer4DomainLoading.Start();
            isEventOccured = false;
            
			//try
			//{
			//    ClsModuleCollection objCMC = null;
			//    objCMC = ClsModuleCollection.GetNonAuthenticatedMod();

			//    for (int j = 0; j < objCMC.Count; j++)
			//    {
			//        objModules.AddModule(objCMC[j].ModuleTitle, objCMC[j].ModuleId + ",ModuleType,False");
			//    }


			//    scrViewTab.Content = cpt.LoadTabControl(0);
			//    cpt.LoadDefaultPage(0, 0, 0, 0);
			//    cpt.AddNewPage();
			//}
			//catch (Exception ex)
			//{
			//    ex.Data.Add("My Key", "pgHome_Loaded()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
			//    ClsException.LogError(ex);
			//    ClsException.WriteToErrorLogFile(ex);
			//}
		}

        void pgHome_EntsvcPageSetSpecialMsg(string from, string to, string msg, clsPageInfo objPageInfo, string IPAddress)
		{
			try
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == to)
				{
                    //Add code for VMuktiGrid
					//cpt.OpenDragPage(lstModInfo, from);
                    objVMuktiGrid.LoadMeetingPage(objPageInfo);

					//if (((Window)this.Parent).WindowState == WindowState.Minimized)
					//{
					if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
					{
						Beep(750, 300);
					}
					//}
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "pgHome_EntsvcPageSetSpecialMsg()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void pgHome_EntsvcUnJoin(string uname)
		{

		}

		void pgHome_EntsvcSetSpecialMsg(string from, string to, string msg, clsModuleInfo objModInfo, string IPAddress)
		{
			try
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == to)
				{
					//MessageBox.Show("pgHome_EntsvcSetSpecialMsg");

                    //Add code for VMuktiGrid
					//cpt.LoadDynamicModules(objModInfo, from);


					//if (((Window)this.Parent).WindowState == WindowState.Minimized)
					//{
					if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
					{
						((Window)this.Parent).BringIntoView();
						Beep(750, 300);
					}
					//}
				}
				else
				{
					if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName != from)
					{
                        //Add code for VMuktiGrid
                        //for (int i = 0; i < cpt.ptc.Items.Count; i++)
                        //{
                        //    if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                        //    {
                        //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                        //        {
                        //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                        //            {
                        //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                        //                {
                        //                    if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).PID == int.Parse(objModInfo.strPodid))
                        //                    {
                        //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(to);
                        //                        ComboItem cbi = new ComboItem();
                        //                        cbi.setName(to);
                        //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi);
                        //                    }
                        //                }
                        //            }
                        //        }
                        //    }
                        //}
					}
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "pgHome_EntsvcSetSpecialMsg()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void pgHome_EntsvcSetRemoveDraggedBuddy(string from, List<string> to, string msg, clsModuleInfo objModInfo, string IPAddress)
		{
			for (int j = 0; j < to.Count; j++)
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == to[j])
				{
					#region Pod Type

					if (objModInfo.strDropType == "Pod Type")
					{
                        //Add code for VMuktiGrid
                        //for (int i = 0; i < cpt.ptc.Items.Count; i++)
                        //{
                        //    if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                        //    {
                        //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                        //        {
                        //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                        //            {
                        //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                        //                {
                        //                    if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).PID == int.Parse(objModInfo.strPodid))
                        //                    {
                        //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);
                        //                        for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                        //                        {
                        //                            if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                        //                            {
                        //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                        //                            }
                        //                        }
                        //                    }
                        //                }
                        //            }
                        //        }
                        //    }
                        //}
						//remove the buddy from respective pod, tab and page
					}

					#endregion

					#region Tab Type
                    //Add code for VMuktiGrid
                    //else if (objModInfo.strDropType == "Tab Type")
                    //{
                    //    for (int i = 0; i < cpt.ptc.Items.Count; i++)
                    //    {
                    //        if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                    //        {
                    //            for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                    //            {
                    //                if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                    //                {
                    //                    ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Remove(from);

                    //                    for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Count; cmbCnt++)
                    //                    {
                    //                        if (((ComboItem)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                    //                        {
                    //                            ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                    //                            break;
                    //                        }
                    //                    }

                    //                    for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                    //                    {
                    //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);

                    //                        for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                    //                        {
                    //                            if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                    //                            {
                    //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                    //                            }
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}


					#endregion

					#region Page Type
                    //Add code for VMuktiGrid
                    //else if (objModInfo.strDropType == "Page Type")
                    //{
                    //    for (int i = 0; i < cpt.ptc.Items.Count; i++)
                    //    {
                    //        if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                    //        {
                    //            ((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged.Remove(from);

                    //            for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.Count; cmbCnt++)
                    //            {
                    //                if (((ComboItem)((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                    //                {
                    //                    ((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                    //                    break;
                    //                }
                    //            }

                    //            for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                    //            {
                    //                if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Header.ToString() != "+")
                    //                {
                    //                    ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Remove(from);

                    //                    for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Count; cmbCnt++)
                    //                    {
                    //                        if (((ComboItem)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                    //                        {
                    //                            ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                    //                            break;
                    //                        }
                    //                    }


                    //                    for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                    //                    {
                    //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);


                    //                        for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                    //                        {
                    //                            if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                    //                            {
                    //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                    //                            }
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}


					#endregion
				}
			}
		}

		void pgHome_EntsvcJoin(string uname)
		{

		}

		void objModules_EntPageItemSelectionChanged(string strTagText, string strContent)
		{
            //Add code for VMuktiGrid
			//cpt.LoadDynamicPage(strTagText, strContent, 0, 0, 0, 0);
            objVMuktiGrid.LoadPage(int.Parse(strTagText));
		}

		private void btnPane_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				if (((ScaleTransform)((TransformGroup)btnPane.GetValue(Button.RenderTransformProperty)).Children[0]).ScaleX == -1)
				{
					this.BeginStoryboard((Storyboard)this.Resources["OnCloseClick"], HandoffBehavior.Compose, false);
					rowDef1.Height = new GridLength(0);
					//btnPane.SetValue(Grid.RowProperty, 1);
					//btnPane.SetValue(Grid.ZIndexProperty, 0);
				}
				else
				{
					this.BeginStoryboard((Storyboard)this.Resources["OnOpenClick"], HandoffBehavior.Compose, true);
					rowDef1.Height = new GridLength(25.0, GridUnitType.Pixel);
					//btnPane.SetValue(Grid.RowProperty, 0);
					//btnPane.SetValue(Grid.ZIndexProperty, 0);

				}
				((ScaleTransform)((TransformGroup)btnPane.GetValue(Button.RenderTransformProperty)).Children[0]).ScaleX *= -1;
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "btnPane_Click()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void objModules_EntCloseModule()
		{
			try
			{
				colDef1.Width = new GridLength(0);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "objModules_EntCloseModule()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		private void btnMExp_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				colDef1.Width = new GridLength(146);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "btnMExp_Click()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void objBuddies_EntCloseBuddies()
		{
			try
			{
				colDef3.Width = new GridLength(0);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "objBuddies_EntCloseBuddies()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		private void btnBList_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				colDef3.Width = new GridLength(146);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "btnBList_Click()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		public void closeTab(object sender, RoutedEventArgs e)
		{
			try
			{
				if (((ClsTabsTabItem)e.Source).TabID.Contains(","))
				{
					//tab
					if (((ClsTabsTabItem)e.Source).Header.ToString() != "+")
					{
						if (((ClsTabsTabItem)e.Source).lstBuddyDragged.Count > 0 || ((ClsTabsTabItem)e.Source).cmbTabBuddy.Items.Count > 0)
						{
							clsModuleInfo cmi = new clsModuleInfo();
							cmi.strPageid = ((ClsTabsTabItem)e.Source).TabID.Split(',')[0];
							cmi.strTabid = ((ClsTabsTabItem)e.Source).TabID;
							cmi.strDropType = "Tab Type";
							try
							{
								if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode)
								{
									App.chNetP2PSuperNodeChannel.svcSetRemoveDraggedBuddy(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, ((ClsTabsTabItem)e.Source).lstBuddyDragged, "CLOSE MODULE", cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
								}
								else
								{
									App.chHttpSuperNodeService.svcSetRemoveDraggedBuddy(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, ((ClsTabsTabItem)e.Source).lstBuddyDragged, "CLOSE MODULE", cmi);
								}
							}
							catch (Exception ex)
							{
								ex.Data.Add("My Key", "closeTab-removebuddy()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
								ClsException.LogError(ex);
								ClsException.WriteToErrorLogFile(ex);
							}
						}
					}
				}
				else
				{
					//page
					if (((ClsTabsTabItem)e.Source).TabID != "0" && ((ClsTabsTabItem)e.Source).TabID != "-1")
					{
						if (((ClsTabsTabItem)e.Source).lstBuddyDragged.Count > 0 || ((ClsTabsTabItem)e.Source).cmbTabBuddy.Items.Count > 0)
						{
							clsModuleInfo cmi = new clsModuleInfo();
							cmi.strPageid = ((ClsTabsTabItem)e.Source).TabID.Split(',')[0];
							cmi.strDropType = "Page Type";
							try
							{
								if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode)
								{
									App.chNetP2PSuperNodeChannel.svcSetRemoveDraggedBuddy(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, ((ClsTabsTabItem)e.Source).lstBuddyDragged, "CLOSE MODULE", cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
								}
								else
								{
									App.chHttpSuperNodeService.svcSetRemoveDraggedBuddy(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, ((ClsTabsTabItem)e.Source).lstBuddyDragged, "CLOSE MODULE", cmi);
								}
							}
							catch (Exception ex)
							{
								ex.Data.Add("My Key", "closeTab-removebuddy()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
								ClsException.LogError(ex);
								ClsException.WriteToErrorLogFile(ex);
							}
						}
					}
				}
                //Add code for VMuktiGrid
				//cpt.tabClose(sender, e);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "closeTab()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		public void renameTab(object sender, RoutedEventArgs e)
		{
			try
			{
                //Add code for VMuktiGrid
				//cpt.tabRename(sender, e);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "renameTab()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		public void deleteTab(object sender, RoutedEventArgs e)
		{
			try
			{
                //Add code for VMuktiGrid
				//cpt.tabDelete(sender, e);
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "deleteTab()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		public void buddyEnterTab(object sender, RoutedEventArgs e)
		{
			try
			{
				if (((ClsTabsTabItem)e.Source).cmbTabBuddy.Items.Count > 0)
				{
					((ClsTabsTabItem)e.Source).cmbTabBuddy.IsDropDownOpen = true;
				}

			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "buddyEnterTab()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		public void buddyLeaveTab(object sender, RoutedEventArgs e)
		{
			try
			{
				if (((ClsTabsTabItem)e.Source).cmbTabBuddy.IsDropDownOpen)
				{
					((ClsTabsTabItem)e.Source).cmbTabBuddy.IsDropDownOpen = false;
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "buddyLeaveTab()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		void cpt_EntChannelSetMsg(string from, string to, string msg, clsModuleInfo cmi)
		{
			try
			{
				if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode)
				{
					App.chNetP2PSuperNodeChannel.svcSetSpecialMsg(from, to, msg, cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
					App.chNetP2PSuperNodeChannel.svcAddDraggedBuddy(from, to, "Newly Dragged Buddy", cmi, VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
				}
				else
				{
					App.chHttpSuperNodeService.svcSetSpecialMsgs(from, to, msg, cmi);
					App.chHttpSuperNodeService.svcAddDraggedBuddy(from, to, "Newly Dragged Buddy", cmi);
				}
			}
			catch (Exception ex)
			{
				ex.Data.Add("My Key", "cpt_EntChannelSetMsg()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
				ClsException.LogError(ex);
				ClsException.WriteToErrorLogFile(ex);
			}
		}

		private void btnSettings_Click(object sender, RoutedEventArgs e)
		{
			cnvSettings.Visibility = Visibility.Visible;
            System.Text.StringBuilder sb = new StringBuilder();
            sb.AppendLine("Home page: user click the setting button");
            
            sb.Append(sb1.ToString());
            VMuktiAPI.ClsLogging.WriteToTresslog(sb);

		}

		void dispTmrCheckStatus_Tick(object sender, EventArgs e)
		{
			try
			{
				System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(StartThread));
				//System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(StartThread));
				t.IsBackground = true;
				t.Priority = System.Threading.ThreadPriority.Normal;
				t.Start();
				((System.Windows.Threading.DispatcherTimer)sender).Stop();
				
			}
			catch (Exception exp)
			{
				exp.Data.Add("My Key", "dispTmrCheckStatus_Tick--:--pgHome.xaml.cs--:--" + exp.Message + " :--:--");
				ClsException.LogError(exp);
				ClsException.WriteToErrorLogFile(exp);
			}
		}

		void StartThread()
		{
			try
			{
				this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, objDelGetMsg);
			}
			catch (Exception exp)
			{
				exp.Data.Add("My Key", "StartThread--:--pgHome.xaml.cs--:--" + exp.Message + " :--:--");
				ClsException.LogError(exp);
				ClsException.WriteToErrorLogFile(exp);
			}
		}
		
		void delGetMessage()
		{
			try
			{
				if (App.chHttpSuperNodeService != null)
				{
					List<clsMessage> lstMsg = App.chHttpSuperNodeService.svcGetSpecialMsgs(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
					if (lstMsg.Count > 0)
					{
						for (int i = 0; i < lstMsg.Count; i++)
						{
                            //New code added by pratik.....Start
                            if (lstMsg[i].strMessage == "OPEN_PAGE")
                            {
                                objVMuktiGrid.LoadMeetingPage(lstMsg[i].objPageInfo);

                                if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
                                {
                                    Beep(750, 300);
                                }
                            }
                            //New code added by pratik.....End

							if (lstMsg[i].lstClsModuleInfo != null && lstMsg[i].lstClsModuleInfo.Count > 0)
							{
								if (lstMsg[i].lstClsModuleInfo[0].strDropType == "Page Type" || lstMsg[i].lstClsModuleInfo[0].strDropType == "Tab Type")
								{
									if (lstMsg[i].strMessage == "Newly Dragged Buddy")
									{
										for (int lstModCnt = 0; lstModCnt < lstMsg[i].lstClsModuleInfo.Count; lstModCnt++)
										{
											#region Tab Type

											if (lstMsg[i].lstClsModuleInfo[lstModCnt].strDropType == "Tab Type")
											{
                                                //Add code for VMuktiGrid
                                                //for (int iCnt = 0; iCnt < cpt.ptc.Items.Count; iCnt++)
                                                //{
                                                //    if (((ClsTabsTabItem)cpt.ptc.Items[iCnt]).TabID.Split(',')[0] == lstMsg[i].lstClsModuleInfo[lstModCnt].strPageid)
                                                //    {
                                                //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items.Count; tCnt++)
                                                //        {
                                                //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).TabID == lstMsg[i].lstClsModuleInfo[lstModCnt].strTabid)
                                                //            {
                                                //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).lstBuddyDragged.Add(lstMsg[i].strTo[0]);

                                                //                ComboItem cbi = new ComboItem();
                                                //                cbi.setName(lstMsg[i].strTo[0]);
                                                //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbi);

                                                //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                                                //                {
                                                //                    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(lstMsg[i].strTo[0]);

                                                //                    for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                                                //                    {
                                                //                        ComboItem cbi1 = new ComboItem();
                                                //                        cbi1.setName(lstMsg[i].strTo[0]);
                                                //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi1);

                                                //                    }
                                                //                }
                                                //            }
                                                //        }
                                                //    }
                                                //}
											}


											#endregion

											#region Page Type

											else if (lstMsg[i].lstClsModuleInfo[lstModCnt].strDropType == "Page Type")
											{
                                                //Add code for VMuktiGrid
                                                //for (int iCnt = 0; iCnt < cpt.ptc.Items.Count; iCnt++)
                                                //{
                                                //    if (((ClsTabsTabItem)cpt.ptc.Items[iCnt]).TabID.Split(',')[0] == lstMsg[i].lstClsModuleInfo[lstModCnt].strPageid)
                                                //    {
                                                //        ((ClsTabsTabItem)cpt.ptc.Items[iCnt]).lstBuddyDragged.Add(lstMsg[i].strTo[0]);

                                                //        ComboItem cbiPage = new ComboItem();
                                                //        cbiPage.setName(lstMsg[i].strTo[0]);

                                                //        ((ClsTabsTabItem)cpt.ptc.Items[iCnt]).cmbTabBuddy.Items.Add(cbiPage);

                                                //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items.Count; tCnt++)
                                                //        {
                                                //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Header.ToString() != "+")
                                                //            {
                                                //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).lstBuddyDragged.Add(lstMsg[i].strTo[0]);

                                                //                ComboItem cbiTab = new ComboItem();
                                                //                cbiTab.setName(lstMsg[i].strTo[0]);

                                                //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).cmbTabBuddy.Items.Add(cbiTab);


                                                //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                                                //                {
                                                //                    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(lstMsg[i].strTo[0]);

                                                //                    ComboItem cbiPod = new ComboItem();
                                                //                    cbiPod.setName(lstMsg[i].strTo[0]);

                                                //                    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbiPod);

                                                //                }
                                                //            }
                                                //        }
                                                //    }
                                                //}
											}


											#endregion
										}
									}
									else
									{
                                        //Add code for VMuktiGrid
										//cpt.OpenDragPage(lstMsg[i].lstClsModuleInfo, lstMsg[i].strFrom);
									}
									if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
									{
										Beep(750, 300);
									}
								}
							}
							else if (lstMsg[i].objClsModuleInfo != null)
							{
								if (lstMsg[i].strMessage == "OPEN_MODULE")
								{
                                    //Add code for VMuktiGrid
									//cpt.LoadDynamicModules(lstMsg[i].objClsModuleInfo, lstMsg[i].strFrom);

									if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
									{
										Beep(750, 300);
									}
								}
								else if (lstMsg[i].strMessage == "Newly Dragged Buddy")
								{
									#region Pod Type

									if (lstMsg[i].objClsModuleInfo.strDropType == "Pod Type")
									{
                                        //Add code for VMuktiGrid
                                        //for (int iCnt = 0; iCnt < cpt.ptc.Items.Count; iCnt++)
                                        //{
                                        //    if (((ClsTabsTabItem)cpt.ptc.Items[iCnt]).TabID.Split(',')[0] == lstMsg[i].objClsModuleInfo.strPageid)
                                        //    {
                                        //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items.Count; tCnt++)
                                        //        {
                                        //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).TabID == lstMsg[i].objClsModuleInfo.strTabid)
                                        //            {
                                        //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                                        //                {
                                        //                    bool blnNamePresent = false;
                                        //                    if (lstMsg[i].strFrom != VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName)
                                        //                    {
                                        //                        if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).PID == int.Parse(lstMsg[i].objClsModuleInfo.strPodid))
                                        //                        {
                                        //                            for (int lstBuddyCnt = 0; lstBuddyCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Count; lstBuddyCnt++)
                                        //                            {
                                        //                                if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped[lstBuddyCnt] == lstMsg[i].strFrom)
                                        //                                {
                                        //                                    blnNamePresent = true;
                                        //                                    break;
                                        //                                }
                                        //                            }


                                        //                            if (!blnNamePresent)
                                        //                            {
                                        //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Add(lstMsg[i].strFrom);
                                        //                                ComboItem cbi = new ComboItem();
                                        //                                cbi.setName(lstMsg[i].strFrom);
                                        //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[iCnt]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Add(cbi);
                                        //                            }
                                        //                        }
                                        //                    }
                                        //                }
                                        //            }
                                        //        }
                                        //    }
                                        //}
									}
									#endregion
									if (((WindowState)(this.Parent.GetValue(Window.WindowStateProperty))) == WindowState.Minimized)
									{
										Beep(750, 300);
									}
								}
								else if (lstMsg[i].strMessage == "CLOSE MODULE")
								{
									HttpRemoveDraggedBuddy(lstMsg[i].strFrom, lstMsg[i].strTo, lstMsg[i].strMessage, lstMsg[i].objClsModuleInfo);
									lstMsg.RemoveAt(i);
								}
							}
						}
					}
				}
				this.dispTmrCheckStatus.Start();
			}
			catch (Exception exp)
			{
				exp.Data.Add("My Key", "delGetMessage--:--pgHome.xaml.cs--:--" + exp.Message + " :--:--");
				ClsException.LogError(exp);
				ClsException.WriteToErrorLogFile(exp);
			}
		}

		public void HttpRemoveDraggedBuddy(string from, string[] to, string msg, clsModuleInfo objModInfo)
		{
			try
			{
				for (int j = 0; j < to.Length; j++)
				{
					if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == to[j])
					{
						#region Pod Type

						if (objModInfo.strDropType == "Pod Type")
						{
                            //Add code for VMuktiGrid
                            //for (int i = 0; i < cpt.ptc.Items.Count; i++)
                            //{
                            //    if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                            //    {
                            //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                            //        {
                            //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                            //            {
                            //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                            //                {
                            //                    if (((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).PID == int.Parse(objModInfo.strPodid))
                            //                    {
                            //                        ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);
                            //                        for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                            //                        {
                            //                            if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //                            {
                            //                                ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                            //                            }
                            //                        }
                            //                    }
                            //                }
                            //            }
                            //        }
                            //    }
                            //}
							//remove the buddy from respective pod, tab and page
						}

						#endregion

						#region Tab Type

						else if (objModInfo.strDropType == "Tab Type")
						{
                            //Add code for VMuktiGrid
                            //for (int i = 0; i < cpt.ptc.Items.Count; i++)
                            //{
                            //    if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                            //    {
                            //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                            //        {
                            //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).TabID == objModInfo.strTabid)
                            //            {
                            //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Remove(from);

                            //                for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Count; cmbCnt++)
                            //                {
                            //                    if (((ComboItem)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //                    {
                            //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                            //                        break;
                            //                    }
                            //                }

                            //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                            //                {
                            //                    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);

                            //                    for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                            //                    {
                            //                        if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //                        {
                            //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                            //                        }
                            //                    }
                            //                }
                            //            }
                            //        }
                            //    }
                            //}
						}


						#endregion

						#region Page Type

						else if (objModInfo.strDropType == "Page Type")
						{
                            //Add code for VMuktiGrid
                            //for (int i = 0; i < cpt.ptc.Items.Count; i++)
                            //{
                            //    if (((ClsTabsTabItem)cpt.ptc.Items[i]).TabID.Split(',')[0] == objModInfo.strPageid)
                            //    {
                            //        ((ClsTabsTabItem)cpt.ptc.Items[i]).lstBuddyDragged.Remove(from);

                            //        for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.Count; cmbCnt++)
                            //        {
                            //            if (((ComboItem)((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //            {
                            //                ((ClsTabsTabItem)cpt.ptc.Items[i]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                            //                break;
                            //            }
                            //        }

                            //        for (int tCnt = 0; tCnt < ((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items.Count; tCnt++)
                            //        {
                            //            if (((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Header.ToString() != "+")
                            //            {
                            //                ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).lstBuddyDragged.Remove(from);

                            //                for (int cmbCnt = 0; cmbCnt < ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.Count; cmbCnt++)
                            //                {
                            //                    if (((ComboItem)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //                    {
                            //                        ((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).cmbTabBuddy.Items.RemoveAt(cmbCnt);
                            //                        break;
                            //                    }
                            //                }


                            //                for (int pCnt = 0; pCnt < ((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children.Count; pCnt++)
                            //                {
                            //                    ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).lstUsersDropped.Remove(from);


                            //                    for (int cmbCnt = 0; cmbCnt < ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.Count; cmbCnt++)
                            //                    {
                            //                        if (((ComboItem)((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items[cmbCnt]).txtBlock.Text == from)
                            //                        {
                            //                            ((CtlPod)((Resizer)((Canvas)((ClsTabsTabItem)((ClsPageTabControl)((ClsTabsTabItem)cpt.ptc.Items[i]).Content).Items[tCnt]).Content).Children[pCnt]).Content).cmbPodBuddy.Items.RemoveAt(cmbCnt);
                            //                        }
                            //                    }
                            //                }
                            //            }
                            //        }
                            //    }
                            //}
						}


						#endregion
					}
				}
			}
			catch (Exception exp)
			{
				MessageBox.Show("HttpRemoveDraggedBuddy " + exp.Message);
			}
		}

		#region IDisposable Members

		public void Dispose()
		{
			Dispose(true);
			GC.SuppressFinalize(this);
		}

		private void Dispose(bool disposing)
		{
			if (!this.disposed)
			{
				if (disposing)
				{
					try
					{
                        //Add code for VMuktiGrid
                        //if (cpt != null)
                        //{
                        //    cpt = null;
                        //}

						//if (dispTimer4DomainLoading != null)
						//{
						//    dispTimer4DomainLoading = null;
						//}
						if (npcP2PSuperNode != null)
						{
							npcP2PSuperNode.CloseClient<INetP2PSuperNodeChannel>();
							npcP2PSuperNode = null;
						}
						if (dispTmrCheckStatus != null)
						{
							dispTmrCheckStatus.Stop();
						}
					}
					catch (Exception ex)
					{
						ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Audio--:--Audio.Presentation--:--ctlDialer.xaml.cs--:--Dispose()--");
						ClsException.LogError(ex);
						ClsException.WriteToErrorLogFile(ex);
					}
				}
				disposed = true;
			}
			GC.SuppressFinalize(this);
		}

		~pgHome()
		{
			Dispose(false);
		}

		#endregion


        #region logging function

        public static StringBuilder CreateTressInfo()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("User Is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
            sb.AppendLine();
            sb.Append("Peer Type is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType.ToString());
            sb.AppendLine();
            sb.Append("User's SuperNode is : " + VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP);
            sb.AppendLine();
            sb.Append("User's Machine Ip Address : " + VMuktiAPI.GetIPAddress.ClsGetIP4Address.GetIP4Address());
            sb.AppendLine();
            sb.AppendLine("----------------------------------------------------------------------------------------");
            return sb;
        }

        #endregion


        #region Monitoring System

        void btnConsole_Click(object sender, RoutedEventArgs e)
        {
            blnISConsole = true;
            pConsole = new Process();
            psiConsole = new ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory + "\\VMuktiMonitor.exe");
            psiConsole.WindowStyle = ProcessWindowStyle.Normal;
            pConsole.Exited += new EventHandler(pConsole_Exited);
            pConsole.StartInfo = psiConsole;
            pConsole.EnableRaisingEvents = true;
            pConsole.Start();
        }

        void pConsole_Exited(object sender, EventArgs e)
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\temp.txt"))
            {
                File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\temp.txt");
            }

        }

        private void OpenConsoleClient()
        {
            try
            {
                NetPeerClient npc = new NetPeerClient();
                ((ClsNetP2PConsoleDelegates)objNetTcpConsole).EntsvcNetP2PConsoleJoin += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleJoin(pgHome_EntsvcNetP2PConsoleJoin);
                ((ClsNetP2PConsoleDelegates)objNetTcpConsole).EntsvcNetP2PConsoleSendMsg += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleSendMsg(pgHome_EntsvcNetP2PConsoleSendMsg);
                ((ClsNetP2PConsoleDelegates)objNetTcpConsole).EntsvcNetP2PConsoleUnJoin += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleUnJoin(pgHome_EntsvcNetP2PConsoleUnJoin);
                objChannel = (INetP2PConsoleChannel)npc.OpenClient<INetP2PConsoleChannel>("net.tcp://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":6000/NetP2PConsole", "ConsoleMesh", ref objNetTcpConsole);
                objChannel.svcNetP2ConsoleJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
            }
            catch (Exception exp)
            {
                //Console.WriteLine("OpenConsoleClient " + exp.Message);
                MessageBox.Show("OpenConsoleClient " + exp.Message);
                exp.Data.Add("My Key", "OpenConsoleClient--:--pgHome.xaml.cs--:--" + exp.Message + " :--:--");
                ClsException.LogError(exp);
                ClsException.WriteToErrorLogFile(exp);
            }

        }

        void pgHome_VMuktiEvent_SendConsoleMsg(object sender, VMuktiEventArgs e)
        {
            try
            {
                objChannel.svcNetP2ConsoleSendMsg((string)e._args[0]);
                
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "pgHome_VMuktiEvent_SendConsoleMsg()--:--pgHome.xaml.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
            }
        }

        void pgHome_EntsvcNetP2PConsoleUnJoin(string uName)
        {

        }

        void pgHome_EntsvcNetP2PConsoleSendMsg(string msg)
        {
            try
            {

                Process[] pnew = Process.GetProcessesByName("VMuktiMonitor");

                if ((VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap) && pnew.Length > 0)
                {
                    FileStream fs;
                    if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\temp.txt"))
                    {
                        fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\temp.txt", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite);
                    }
                    else
                    {
                        fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\temp.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                    }
                    StreamWriter sw = new StreamWriter(fs);
                    sw.WriteLine(msg);
                    fs.Flush();
                    sw.Flush();
                    sw.Dispose();
                    sw = null;
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("pgHome_EntsvcNetP2PConsoleSendMsg " + exp.Message);
                exp.Data.Add("My Key", "pgHome_EntsvcNetP2PConsoleSendMsg--:--pgHome.xaml.cs--:--" + exp.Message + " :--:--");
                ClsException.LogError(exp);
                ClsException.WriteToErrorLogFile(exp);
            }
        }

        void pgHome_EntsvcNetP2PConsoleJoin(string uName)
        {

        }

        #endregion

	}
}
